import java.util.Stack;

class MyQueue {

    //用栈实现队列
    public Stack<Integer> sta1;
    public Stack<Integer> sta2;

    public MyQueue() {
        sta1 = new Stack<>();
        sta2 = new Stack<>();
    }
    
    public void push(int x) {
        sta1.push(x);
    }
    
    public int pop() {
        if(empty()){
            return -1;
        }
        if(sta2.isEmpty()){
            while (!sta1.isEmpty()){
                sta2.push(sta1.pop());
            }
        }
        return sta2.pop();
    }
    
    public int peek() {
        if(empty()){
            return -1;
        }
        if(sta2.isEmpty()){
            while (!sta1.isEmpty()){
                sta2.push(sta1.pop());
            }
        }
        return sta2.peek();
    }
    
    public boolean empty() {
        return (sta1.isEmpty() && sta2.isEmpty());
    }
}